﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;

namespace 画面XML文件反序列化
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var xs = new XmlSerializer(typeof(Document));

            using (Stream s = File.OpenRead(@"D:\A2A22001A&A2B22082A-FCC EOL& FA\程序\画面\Screens\画面_2.xml"))
            {
                var screen_1 = (Document)xs.Deserialize(s);
                Console.WriteLine(screen_1.HmiScreenScreen.ObjectList.HmiScreenScreenLayer.First().ObjectList.HmiScreenRectangle.First().AttributeList.ObjectName);

                FileStream s_2 = new FileStream(@"D:\A2A22001A&A2B22082A-FCC EOL& FA\程序\画面\Screens\新生成.xml", FileMode.Create, FileAccess.ReadWrite);
                XmlSerializerNamespaces _namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {new XmlQualifiedName(string.Empty, "aa")});
                TextWriter writer2 = new StreamWriter(s_2, Encoding.UTF8);
                xs.Serialize(writer2, screen_1, _namespaces);
                s_2.Close();
            }
            Console.ReadKey();
            

        }
    }
}
